#include <iostream>

using namespace std;

#define MAXN 1005
int seq[MAXN];
int n;

void swap(int i, int j) {
    int temp = seq[i];
    seq[i] = seq[j];
    seq[j] = temp;
};

int Process() {
    bool bOver = false;
    int sum = 0;
    
    for (int i = 0; i < n && bOver == false; ++i) {
        bOver = true;
        for (int j = n-1; j > i; j--) {
            if (seq[j] < seq[j-1]) {
                sum++;
                bOver = false;
                swap(j, j-1);
            }
        }
    }
    return sum;
}

int main() {
    int T;

    cin >> T;
    for (int t = 1; t <= T; t++) {
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> seq[i];
        }

        cout << "Scenario #" << t << ":\n"
            << Process()
            << endl;
        cout << endl;

    }
    return 0;
}
